home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / Amos / AMOSP61Ext / source / 610.2_devpac3.asm next >
Encoding:
Assembly Source File  |  1998-06-24  |  38.4 KB  |  2,482 lines

  1. * The Player 6.1A for Devpac 3 (and later ;) *
  2. * NEEDS:
  3. *        Default sizes must be words (ASM-One default...)
  4. *        Preferably no optimizations on (the jump table must be word jumps)
  5. * Tested with Devpac 3.04
  6.         
  7. ;start = 6    ;Starting position
  8.  
  9.  
  10. ;    incdir    include:
  11. ;    include Player61.i
  12.  
  13.  
  14. ;    section    Player6.1A,code
  15.  
  16. *********************************
  17. *        Player 6.1A ®        *
  18. *      All in one-version    *
  19. *        Version 610.2        *
  20. *   © 1992-95 Jarno Paananen    *
  21. *     All rights reserved    *
  22. *********************************
  23.  
  24.  
  25. ******** START OF BINARY FILE **************
  26.  
  27. P61_motuuli
  28. ;    bra.w    P61_Init
  29. ;    ifeq    CIA
  30. ;    bra.w    P61_Music
  31. ;    else
  32. ;    rts
  33. ;    rts
  34. ;    endc
  35. ;    bra.w    P61_End
  36. ;    rts                ;no P61_SetRepeat
  37. ;    rts
  38. ;    bra.w    P61_SetPosition
  39.  
  40. P61_Master    dc    64        ;Master volume (0-64)
  41. P61_FadeTo    dc    64        ;Target volume (0-64)
  42. P61_FadeSpeed    dc    1        ;Speed for fading
  43. P61_FadeCount    dc    0        ;Count for fading
  44. P61_Tempo    dc    1        ;Use tempo? 0=no,non-zero=yes
  45. P61_Play    dc    1        ;Stop flag (0=stop)
  46. P61_E8        dc    0        ;Info nybble after command E8
  47. P61_VBR        dc.l    0        ;If you're using non-valid execbase
  48.                     ;put VBR here! (Otherwise 0 assumed)
  49.                     ;You can also get VBR from here, if
  50.                     ;using exec-valid version
  51.  
  52. P61_Pos        dc    0        ;Current song position
  53. P61_Patt    dc    0        ;Current pattern
  54. P61_CRow    dc    0        ;Current pattern row
  55.  
  56. P61_Temp0Offset
  57.     dc.l    P61_temp0-P61_motuuli
  58. P61_Temp1Offset
  59.     dc.l    P61_temp1-P61_motuuli
  60. P61_Temp2Offset
  61.     dc.l    P61_temp2-P61_motuuli
  62. P61_Temp3Offset
  63.     dc.l    P61_temp3-P61_motuuli
  64.  
  65. P61_getnote    macro
  66.     moveq    #$7e,d0
  67.     and.b    (a5),d0
  68.     beq.b    .nonote
  69.     ifne    P61_vib
  70.     clr.b    P61_VibPos(a5)
  71.     endc
  72.     ifne    P61_tre
  73.     clr.b    P61_TrePos(a5)
  74.     endc
  75.  
  76.     ifne    P61_ft
  77.     add    P61_Fine(a5),d0
  78.     endc
  79.     move    d0,P61_Note(a5)
  80.     move    (a2,d0),P61_Period(a5)
  81.  
  82. .nonote
  83.     endm
  84.  
  85.     ifeq    system
  86.     ifne    CIA
  87. P61_intti
  88.     movem.l    d0-a6,-(sp)
  89.     tst.b    $bfdd00
  90.     lea    $dff000,a6
  91.     move    #$2000,$9c(a6)
  92. ;    move    #$fff,$180(a6)
  93.     bsr    P61_Music
  94. ;    move    #0,$180(a6)
  95.     movem.l    (sp)+,d0-a6
  96.     nop
  97.     rte
  98.     endc
  99.     endc
  100.  
  101.     ifne    system
  102. P61_lev6server
  103.     movem.l    d2-d7/a2-a6,-(sp)
  104.     lea    P61_timeron(pc),a0
  105.     tst    (a0)
  106.     beq.b    P61_ohi
  107.  
  108.     lea    $dff000,a6
  109.     move    P61_server(pc),d0
  110.     beq.b    P61_musica
  111.     subq    #1,d0
  112.     beq    P61_dmason
  113.     bra    P61_setrepeat
  114.  
  115. P61_musica
  116.     bsr    P61_Music
  117.  
  118. P61_ohi    movem.l    (sp)+,d2-d7/a2-a6
  119.     moveq    #1,d0
  120.     rts
  121.     endc
  122.  
  123. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  124. ;­ Call P61_Init to initialize the playroutine    ­
  125. ;­ D0 --> Timer detection (for CIA-version)    ­
  126. ;­ A0 --> Address to the module            ­
  127. ;­ A1 --> Address to samples/0 if in the module    ­
  128. ;­ A2 --> Address to sample buffer        ­
  129. ;­ D0 <-- 0 if succeeded            ­
  130. ;­ A6 <-- $DFF000                ­
  131. ;­         Uses D0-A6            ­
  132. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  133.  
  134. P61_Init
  135.     cmp.l    #"P61A",(a0)+
  136.     beq.b    .modok
  137.     subq.l    #4,a0
  138.  
  139. .modok
  140.     ifne    CIA
  141.     move    d0,-(sp)
  142.     endc
  143.  
  144.     moveq    #0,d0
  145.     cmp.l    d0,a1
  146.     bne.b    .redirect
  147.  
  148.     move    (a0),d0
  149.     lea    (a0,d0.l),a1
  150. .redirect
  151.     move.l    a2,a6
  152.     lea    8(a0),a2
  153.     moveq    #$40,d0
  154.     and.b    3(a0),d0
  155.     bne.b    .buffer
  156.     move.l    a1,a6
  157.     subq.l    #4,a2
  158. .buffer
  159.  
  160.     lea    P61_cn(pc),a3
  161.     moveq    #$1f,d1
  162.     and.b    3(a0),d1
  163.     move.l    a0,-(sp)
  164.     lea    P61_samples(pc),a4
  165.     subq    #1,d1
  166.     moveq    #0,d4
  167. P61_lopos
  168.     move.l    a6,(a4)+
  169.     move    (a2)+,d4
  170.     bpl.b    P61_kook
  171.     neg    d4
  172.     lea    P61_samples-16(pc),a5
  173.     ifeq    opt020
  174.     asl    #4,d4
  175.     move.l    (a5,d4),d6
  176.     else
  177.     add    d4,d4
  178.     move.l    (a5,d4*8),d6
  179.     endc
  180.     move.l    d6,-4(a4)
  181.     move    4(a5,d4),d4
  182.     sub.l    d4,a6
  183.     sub.l    d4,a6
  184.     bra.b    P61_jatk
  185.  
  186. P61_kook
  187.     move.l    a6,d6
  188.     tst.b    3(a0)
  189.     bpl.b    P61_jatk
  190.  
  191.     tst.b    (a2)
  192.     bmi.b    P61_jatk
  193.  
  194.     move    d4,d0
  195.     subq    #2,d0
  196.     bmi.b    P61_jatk
  197.  
  198.     move.l    a1,a5
  199.     move.b    (a5)+,d2
  200.     sub.b    (a5),d2
  201.     move.b    d2,(a5)+
  202. .loop    sub.b    (a5),d2
  203.     move.b    d2,(a5)+
  204.     sub.b    (a5),d2
  205.     move.b    d2,(a5)+
  206.     dbf    d0,.loop
  207.  
  208. P61_jatk
  209.     move    d4,(a4)+
  210.     moveq    #0,d2
  211.     move.b    (a2)+,d2
  212.     moveq    #0,d3
  213.     move.b    (a2)+,d3
  214.  
  215.     moveq    #0,d0
  216.     move    (a2)+,d0
  217.     bmi.b    .norepeat
  218.  
  219.     move    d4,d5
  220.     sub    d0,d5
  221.     move.l    d6,a5
  222.  
  223.     add.l    d0,a5
  224.     add.l    d0,a5
  225.  
  226.     move.l    a5,(a4)+
  227.     move    d5,(a4)+
  228.     bra.b    P61_gene
  229. .norepeat
  230.     move.l    d6,(a4)+
  231.     move    #1,(a4)+
  232. P61_gene
  233.     move    d3,(a4)+
  234.     moveq    #$f,d0
  235.     and    d2,d0
  236.     mulu    #74,d0
  237.     move    d0,(a4)+
  238.  
  239.     tst    -6(a2)
  240.     bmi.b    .nobuffer
  241.  
  242.     moveq    #$40,d0
  243.     and.b    3(a0),d0
  244.     beq.b    .nobuffer
  245.  
  246.     move    d4,d7
  247.     tst.b    d2
  248.     bpl.b    .copy
  249.  
  250.     subq    #1,d7
  251.     moveq    #0,d5
  252.     moveq    #0,d4
  253. .lo    move.b    (a1)+,d4
  254.     moveq    #$f,d3
  255.     and    d4,d3
  256.     lsr    #4,d4
  257.  
  258.     sub.b    .table(pc,d4),d5
  259.     move.b    d5,(a6)+
  260.     sub.b    .table(pc,d3),d5
  261.     move.b    d5,(a6)+
  262.     dbf    d7,.lo
  263.     bra.b    .kop
  264.  
  265. .copy    add    d7,d7
  266.     subq    #1,d7
  267. .cob    move.b    (a1)+,(a6)+
  268.     dbf    d7,.cob
  269.     bra.b    .kop
  270.  
  271. .table dc.b    0,1,2,4,8,16,32,64,128,-64,-32,-16,-8,-4,-2,-1
  272.  
  273. .nobuffer
  274.     move.l    d4,d6
  275.     add.l    d6,d6
  276.     add.l    d6,a6
  277.     add.l    d6,a1
  278. .kop    dbf    d1,P61_lopos
  279.  
  280.     move.l    (sp)+,a0
  281.     and.b    #$7f,3(a0)
  282.  
  283.     move.l    a2,-(sp)
  284.  
  285.     lea    P61_temp0(pc),a1
  286.     lea    P61_temp1(pc),a2
  287.     lea    P61_temp2(pc),a4
  288.     lea    P61_temp3(pc),a5
  289.     moveq    #Channel_Block_SIZE/2-2,d0
  290.  
  291.     moveq    #0,d1
  292. .cl    move    d1,(a1)+
  293.     move    d1,(a2)+
  294.     move    d1,(a4)+
  295.     move    d1,(a5)+
  296.     dbf    d0,.cl
  297.  
  298.     lea    P61_temp0-P61_cn(a3),a1
  299.     lea    P61_emptysample-P61_cn(a3),a2
  300.     moveq    #channels-1,d0
  301. .loo    move.l    a2,P61_Sample(a2)
  302.     dbf    d0,.loo
  303.  
  304.     move.l    (sp)+,a2
  305.     move.l    a2,P61_positionbase-P61_cn(a3)
  306.  
  307.     moveq    #$7f,d1
  308.     and.b    2(a0),d1
  309.  
  310.     ifeq    opt020
  311.     lsl    #3,d1
  312.     lea    (a2,d1.l),a4
  313.     else
  314.     lea    (a2,d1.l*8),a4
  315.     endc
  316.     move.l    a4,P61_possibase-P61_cn(a3)
  317.  
  318.     move.l    a4,a1
  319.     moveq    #-1,d0
  320. .search    cmp.b    (a1)+,d0
  321.     bne.b    .search
  322.     move.l    a1,P61_patternbase-P61_cn(a3)    
  323.     move.l    a1,d0
  324.     sub.l    a4,d0
  325.     move    d0,P61_slen-P61_cn(a3)
  326.  
  327. ;    ifd    start
  328. ;    lea    start(a4),a4
  329. ;    endc
  330.  
  331.     moveq    #0,d0
  332.     move.b    (a4)+,d0
  333.     move.l    a4,P61_spos-P61_cn(a3)
  334.     lsl    #3,d0
  335.     add.l    d0,a2
  336.  
  337.     move.l    a1,a4
  338.     moveq    #0,d0    
  339.     move    (a2)+,d0
  340.     lea    (a4,d0.l),a1
  341.     move.l    a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  342.     move    (a2)+,d0
  343.     lea    (a4,d0.l),a1
  344.     move.l    a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  345.     move    (a2)+,d0
  346.     lea    (a4,d0.l),a1
  347.     move.l    a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  348.     move    (a2)+,d0
  349.     lea    (a4,d0.l),a1
  350.     move.l    a1,P61_ChaPos+P61_temp3-P61_cn(a3)
  351.  
  352.     lea    P61_setrepeat(pc),a0
  353.     move.l    a0,P61_intaddr-P61_cn(a3)
  354.  
  355.     move    #63,P61_rowpos-P61_cn(a3)
  356.     move    #6,P61_speed-P61_cn(a3)
  357.     move    #5,P61_speed2-P61_cn(a3)
  358.     clr    P61_speedis1-P61_cn(a3)
  359.  
  360.     ifne    P61_pl
  361.     clr.l    P61_plcount-P61_cn(a3)
  362.     endc
  363.  
  364.     ifne    P61_pde
  365.     clr    P61_pdelay-P61_cn(a3)
  366.     clr    P61_pdflag-P61_cn(a3)
  367.     endc
  368.     clr    (a3)
  369.  
  370.     moveq    #2,d0
  371.     and.b    $bfe001,d0
  372.     move.b    d0,P61_ofilter-P61_cn(a3)
  373.     bset    #1,$bfe001
  374.  
  375.     ifeq    system
  376.     ifne    exec
  377.     move.l    4.w,a6
  378.     moveq    #0,d0
  379.     btst    d0,297(a6)
  380.     beq.b    .no68010
  381.  
  382.     lea    P61_liko(pc),a5
  383.     jsr    -$1e(a6)
  384.  
  385. .no68010
  386.     move.l    d0,P61_VBR-P61_cn(a3)
  387.     endc
  388.  
  389.     move.l    P61_VBR-P61_cn(a3),a0
  390.     lea    $78(a0),a0
  391.     move.l    a0,P61_vektori-P61_cn(a3)
  392.  
  393.     move.l    (a0),P61_oldlev6-P61_cn(a3)
  394.     lea    P61_dmason(pc),a1
  395.     move.l    a1,(a0)
  396.     endc
  397.  
  398.     moveq    #0,d0
  399.     lea    $dff000,a6
  400.     move    d0,$a8(a6)
  401.     move    d0,$b8(a6)
  402.     move    d0,$c8(a6)
  403.     move    d0,$d8(a6)
  404.     move    #$f,$96(a6)
  405.  
  406.     ifeq    system
  407.     lea    P61_dmason(pc),a1
  408.     move.l    a1,(a0)
  409.     move    #$2000,$9a(a6)
  410.     lea    $bfd000,a0
  411.     lea    P61_timers(pc),a1
  412.     move.b    #$7f,$d00(a0)
  413.     move.b    #$10,$e00(a0)
  414.     move.b    #$10,$f00(a0)
  415.     move.b    $400(a0),(a1)+
  416.     move.b    $500(a0),(a1)+
  417.     move.b    $600(a0),(a1)+
  418.     move.b    $700(a0),(a1)
  419.     endc
  420.  
  421.     ifeq    system!CIA
  422.     move.b    #$82,$d00(a0)
  423.     endc
  424.  
  425.     ifne    CIA
  426.     move    (sp)+,d0
  427.     subq    #1,d0
  428.     beq.b    P61_ForcePAL
  429.     subq    #1,d0
  430.     beq.b    P61_NTSC
  431.     ifne    exec
  432.     move.l    4.w,a1
  433.     cmp.b    #60,$213(a1)    ;PowerSupplyFrequency
  434.     beq.b    P61_NTSC
  435.     endc
  436. P61_ForcePAL
  437.     move.l    #1773447,d0    ;PAL
  438.     bra.b    P61_setcia
  439. P61_NTSC
  440.     move.l    #1789773,d0    ;NTSC
  441. P61_setcia
  442.     move.l    d0,P61_timer-P61_cn(a3)
  443.     divu    #125,d0
  444.     move    d0,P61_thi2-P61_cn(a3)
  445.     sub    #$1f0*2,d0
  446.     move    d0,P61_thi-P61_cn(a3)
  447.  
  448.     ifeq    system
  449.     move    P61_thi2-P61_cn(a3),d0
  450.     move.b    d0,$400(a0)
  451.     lsr    #8,d0
  452.     move.b    d0,$500(a0)
  453.     lea    P61_intti(pc),a1
  454.     move.l    a1,P61_tintti-P61_cn(a3)
  455.     move.l    P61_vektori(pc),a2
  456.     move.l    a1,(a2)
  457.     move.b    #$83,$d00(a0)
  458.     move.b    #$11,$e00(a0)
  459.     endc
  460.     endc
  461.  
  462.     ifeq    system
  463.     move    #$e000,$9a(a6)
  464.     moveq    #0,d0
  465.     rts
  466.  
  467.     ifne    exec
  468. P61_liko
  469.     dc.l    $4E7A0801        ;MOVEC    VBR,d0
  470.     rte
  471.     endc
  472.     endc
  473.  
  474.     ifne    system
  475.     move.l    a6,-(sp)
  476.  
  477.     ifne    CIA
  478.     clr    P61_server-P61_cn(a3)
  479.     else
  480.     move    #1,P61_server-P61_cn(a3)
  481.     endc
  482.  
  483.     move.l    4.w,a6
  484.     moveq    #-1,d0
  485.     jsr    -$14a(a6)
  486.     move.b    d0,P61_sigbit-P61_cn(a3)
  487.     bmi    P61_err
  488.  
  489.     lea    P61_allocport(pc),a1
  490.     move.l    a1,P61_portti-P61_cn(a3)
  491.     move.b    d0,15(a1)
  492.     move.l    a1,-(sp)
  493.     suba.l    a1,a1
  494.     jsr    -$126(a6)
  495.     move.l    (sp)+,a1
  496.     move.l    d0,16(a1)
  497.     lea    P61_reqlist(pc),a0
  498.     move.l    a0,(a0)
  499.     addq.l    #4,(a0)
  500.     clr.l    4(a0)
  501.     move.l    a0,8(a0)
  502.  
  503.     lea    P61_dat(pc),a1
  504.     move.l    a1,P61_reqdata-P61_cn(a3)
  505.     lea    P61_allocreq(pc),a1
  506.     lea    P61_audiodev(pc),a0
  507.     moveq    #0,d0
  508.     moveq    #0,d1
  509.     jsr    -$1bc(a6)
  510.     tst.l    d0
  511.     bne    P61_err
  512.     st.b    P61_audioopen-P61_cn(a3)
  513.  
  514.     lea    P61_timerint(pc),a1
  515.     move.l    a1,P61_timerdata-P61_cn(a3)
  516.     lea    P61_lev6server(pc),a1
  517.     move.l    a1,P61_timerdata+8-P61_cn(a3)
  518.  
  519.     moveq    #0,d3
  520.     lea    P61_cianame(pc),a1
  521. P61_openciares
  522.     moveq    #0,d0
  523.     move.l    4.w,a6
  524.     jsr    -$1f2(a6)
  525.     move.l    d0,P61_ciares-P61_cn(a3)
  526.     beq.b    P61_err
  527.     move.l    d0,a6
  528.     lea    P61_timerinterrupt(pc),a1
  529.     moveq    #0,d0
  530.     jsr    -6(a6)
  531.     tst.l    d0
  532.     beq.b    P61_gottimer
  533.     addq.l    #4,d3
  534.     lea    P61_timerinterrupt(pc),a1
  535.     moveq    #1,d0
  536.     jsr    -6(a6)
  537.     tst.l    d0
  538.     bne.b    P61_err
  539.  
  540. P61_gottimer
  541.     lea    P61_craddr+8(pc),a6
  542.     move.l    P61_ciaaddr(pc,d3),d0
  543.     move.l    d0,(a6)
  544.     sub    #$100,d0
  545.     move.l    d0,-(a6)
  546.     moveq    #2,d3
  547.     btst    #9,d0
  548.     bne.b    P61_timerB
  549.     subq.b    #1,d3
  550.     add    #$100,d0
  551. P61_timerB
  552.     add    #$900,d0
  553.     move.l    d0,-(a6)
  554.     move.l    d0,a0
  555.     and.b    #%10000000,(a0)
  556.     move.b    d3,P61_timeropen-P61_cn(a3)
  557.     moveq    #0,d0
  558.     ifne    CIA
  559.     move.l    P61_craddr+4(pc),a1
  560.     move.b    P61_tlo(pc),(a1)
  561.     move.b    P61_thi(pc),$100(a1)
  562.     endc
  563.     or.b    #$19,(a0)
  564.     st    P61_timeron-P61_cn(a3)
  565. P61_pois
  566.     move.l    (sp)+,a6
  567.     rts
  568.  
  569. P61_err    moveq    #-1,d0
  570.     bra.b    P61_pois
  571.     rts
  572.  
  573. P61_ciaaddr
  574.     dc.l    $bfd500,$bfd700
  575.     endc
  576.  
  577. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  578. ;­         Call P61_End to stop the music        ­
  579. ;­   A6 --> Customchip baseaddress ($DFF000)    ­
  580. ;­        Uses D0/D1/A0/A1/A3        ­
  581. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  582.  
  583. P61_End    moveq    #0,d0
  584.     move    d0,$a8(a6)
  585.     move    d0,$b8(a6)
  586.     move    d0,$c8(a6)
  587.     move    d0,$d8(a6)
  588.     move    #$f,$96(a6)
  589.  
  590.     and.b    #~2,$bfe001
  591.     move.b    P61_ofilter(pc),d0
  592.     or.b    d0,$bfe001
  593.  
  594.     ifeq    system
  595.     move    #$2000,$9a(a6)
  596.     move.l    P61_vektori(pc),a0
  597.     move.l    P61_oldlev6(pc),(a0)
  598.     lea    $bfd000,a0
  599.     lea    P61_timers(pc),a1
  600.     move.b    (a1)+,$400(a0)
  601.     move.b    (a1)+,$500(a0)
  602.     move.b    (a1)+,$600(a0)
  603.     move.b    (a1)+,$700(a0)
  604.     move.b    #$10,$e00(a0)
  605.     move.b    #$10,$f00(a0)
  606.  
  607.     else
  608.  
  609.     clr    P61_timeron-P61_cn(a3)
  610.     move.l    a6,-(sp)
  611.     lea    P61_cn(pc),a3
  612.     moveq    #0,d0
  613.     move.b    P61_timeropen(pc),d0
  614.     beq.b    P61_rem1
  615.     move.l    P61_ciares(pc),a6
  616.     lea    P61_timerinterrupt(pc),a1
  617.     subq.b    #1,d0
  618.     jsr    -12(a6)
  619. P61_rem1
  620.     move.l    4.w,a6
  621.     tst.b    P61_audioopen-P61_cn(a3)
  622.     beq.b    P61_rem2
  623.     lea    P61_allocreq(pc),a1
  624.     jsr    -$1c2(a6)
  625.     clr.b    P61_audioopen-P61_cn(a3)
  626. P61_rem2
  627.     moveq    #0,d0
  628.     move.b    P61_sigbit(pc),d0
  629.     bmi.b    P61_rem3
  630.     jsr    -$150(a6)
  631.     st    P61_sigbit-P61_cn(a3)
  632. P61_rem3
  633.     move.l    (sp)+,a6
  634.     endc
  635.     rts
  636.  
  637.     ifne    fade
  638. P61_mfade
  639.     lea    P61_Master(pc),a0
  640.     move    (a0),d0
  641.     move.w    P61_FadeTo(pc),d1
  642.     cmp.w    d1,d0
  643.     beq.s    .skip
  644.     blt.s    .add
  645.     subq.w    #2,d0
  646. .add    addq.w    #1,d0
  647.     subq.w    #1,P61_FadeCount-P61_Master(a0)
  648.     bgt.s    .skip
  649.     move.w    P61_FadeSpeed-P61_Master(a0),P61_FadeCount-P61_Master(a0)
  650.     move.w    d0,(a0)
  651. .skip    move    P61_temp0+P61_Shadow(pc),d1
  652.     mulu    d0,d1
  653.     lsr    #6,d1
  654.     move    d1,$a8(a6)
  655.  
  656.     ifgt    channels-1
  657.     move    P61_temp1+P61_Shadow(pc),d1
  658.     mulu    d0,d1
  659.     lsr    #6,d1
  660.     move    d1,$b8(a6)
  661.     endc
  662.  
  663.     ifgt    channels-2
  664.     move    P61_temp2+P61_Shadow(pc),d1
  665.     mulu    d0,d1
  666.     lsr    #6,d1
  667.     move    d1,$c8(a6)
  668.     endc
  669.  
  670.     ifgt    channels-3
  671.     move    P61_temp3+P61_Shadow(pc),d1
  672.     mulu    d0,d1
  673.     lsr    #6,d1
  674.     move    d1,$d8(a6)
  675.     endc
  676.     rts
  677.     endc
  678.     
  679.  
  680. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  681. ;­ Call P61_SetPosition to jump to a specific    ­
  682. ;­          position in the song.        ­
  683. ;­ D0.l --> Position                ­
  684. ;­ Starts from the beginning if out of limits.    ­
  685. ;­              Uses A0/A1/A3/D0-D3        ­
  686. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  687.  
  688.     ifne    jump
  689. P61_SetPosition
  690.     lea    P61_cn(pc),a3
  691.     ifne    P61_pl
  692.     clr    P61_plflag-P61_cn(a3)
  693.     endc
  694.     moveq    #0,d1
  695.     move.b    d0,d1
  696.     move.l    d1,d0
  697.     cmp    P61_slen-P61_cn(a3),d0
  698.     blo.b    .e
  699.     moveq    #0,d0
  700. .e    move    d0,P61_Pos-P61_cn(a3)
  701.     add.l    P61_possibase(pc),d0
  702.     move.l    d0,P61_spos-P61_cn(a3)
  703.  
  704.     moveq    #64,d0
  705.     move    d0,P61_rowpos-P61_cn(a3)
  706.     clr    P61_CRow-P61_cn(a3)
  707.     move.l    P61_spos(pc),a1
  708.     move.l    P61_patternbase(pc),a0
  709.     addq    #1,P61_Pos-P61_cn(a3)
  710.     move.b    (a1)+,d0
  711.     move.l    a1,P61_spos-P61_cn(a3)
  712.     move.l    P61_positionbase(pc),a1
  713.     move    d0,P61_Patt-P61_cn(a3)
  714.     lsl    #3,d0
  715.     add.l    d0,a1
  716.     movem    (a1),d0-d3
  717.     lea    (a0,d0.l),a1
  718.     move    d1,d0
  719.     move.l    a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  720.     lea    (a0,d0.l),a1
  721.     move.l    a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  722.     move    d2,d0
  723.     lea    (a0,d0.l),a1
  724.     move.l    a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  725.     move    d3,d0
  726.     add.l    d0,a0
  727.     move.l    a0,P61_ChaPos+P61_temp3-P61_cn(a3)
  728.     rts
  729.     endc
  730.  
  731. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  732. ;­ Call P61_Music every frame to play the music    ­
  733. ;­      _NOT_ if CIA-version is used!        ­
  734. ;­ A6 --> Customchip baseaddress ($DFF000)    ­
  735. ;­              Uses A0-A5/D0-D7        ­
  736. ;­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
  737.  
  738. P61_Music
  739.     lea    P61_cn(pc),a3
  740.  
  741.     tst    P61_Play-P61_cn(a3)
  742.     bne.b    P61_ohitaaa
  743.     ifne    CIA
  744.     ifne    system
  745.     move.l    P61_craddr+4(pc),a0
  746.     move.b    P61_tlo2(pc),(a0)
  747.     move.b    P61_thi2(pc),$100(a0)
  748.     endc
  749.     endc
  750.     rts
  751.  
  752. P61_ohitaaa
  753.     ifne    fade
  754.     pea    P61_mfade(pc)
  755.     endc
  756.  
  757.     moveq    #Channel_Block_SIZE,d6
  758.     moveq    #16,d7
  759.  
  760.     move    (a3),d4
  761.     addq    #1,d4
  762.     cmp    P61_speed(pc),d4
  763.     beq    P61_playtime
  764.  
  765.     move    d4,(a3)
  766.  
  767. P61_delay
  768.     ifne    CIA
  769.     ifne    system
  770.     move.l    P61_craddr+4(pc),a0
  771.     move.b    P61_tlo2(pc),(a0)
  772.     move.b    P61_thi2(pc),$100(a0)
  773.     endc
  774.     endc
  775.  
  776.     lea    P61_temp0(pc),a5
  777.     lea    $a0(a6),a4
  778.  
  779.     moveq    #channels-1,d5
  780. P61_lopas
  781.     tst    P61_OnOff(a5)
  782.     beq    P61_contfxdone
  783.     moveq    #$f,d0
  784.     and    (a5),d0
  785.     ifeq    opt020
  786.     add    d0,d0
  787.     move    P61_jtab2(pc,d0),d0
  788.     else
  789.     move    P61_jtab2(pc,d0*2),d0
  790.     endc
  791.     jmp    P61_jtab2(pc,d0)
  792.  
  793. P61_jtab2
  794.     dc    P61_contfxdone-P61_jtab2
  795.  
  796.     ifne    P61_pu
  797.     dc    P61_portup-P61_jtab2
  798.     else
  799.     dc    P61_contfxdone-P61_jtab2
  800.     endc
  801.  
  802.     ifne    P61_pd
  803.     dc    P61_portdwn-P61_jtab2
  804.     else
  805.     dc    P61_contfxdone-P61_jtab2
  806.     endc
  807.  
  808.     ifne    P61_tp
  809.     dc    P61_toneport-P61_jtab2
  810.     else
  811.     dc    P61_contfxdone-P61_jtab2
  812.     endc
  813.  
  814.     ifne    P61_vib
  815.     dc    P61_vib2-P61_jtab2
  816.     else
  817.     dc    P61_contfxdone-P61_jtab2
  818.     endc
  819.  
  820.     ifne    P61_tpvs
  821.     dc    P61_tpochvslide-P61_jtab2
  822.     else
  823.     dc    P61_contfxdone-P61_jtab2
  824.     endc
  825.  
  826.     ifne    P61_vbvs
  827.     dc    P61_vibochvslide-P61_jtab2
  828.     else
  829.     dc    P61_contfxdone-P61_jtab2
  830.     endc
  831.  
  832.     ifne    P61_tre
  833.     dc    P61_tremo-P61_jtab2
  834.     else
  835.     dc    P61_contfxdone-P61_jtab2
  836.     endc
  837.  
  838.     ifne    P61_arp
  839.     dc    P61_arpeggio-P61_jtab2
  840.     else
  841.     dc    P61_contfxdone-P61_jtab2
  842.     endc
  843.  
  844.     dc    P61_contfxdone-P61_jtab2
  845.  
  846.     ifne    P61_vs
  847.     dc    P61_volslide-P61_jtab2
  848.     else
  849.     dc    P61_contfxdone-P61_jtab2
  850.     endc
  851.  
  852.     dc    P61_contfxdone-P61_jtab2
  853.     dc    P61_contfxdone-P61_jtab2
  854.     dc    P61_contfxdone-P61_jtab2
  855.  
  856.     ifne    P61_ec
  857.     dc    P61_contecommands-P61_jtab2
  858.     else
  859.     dc    P61_contfxdone-P61_jtab2
  860.     endc
  861.     dc    P61_contfxdone-P61_jtab2
  862.  
  863.     ifne    P61_ec
  864. P61_contecommands
  865.     move.b    P61_Info(a5),d0
  866.     and    #$f0,d0
  867.     lsr    #3,d0
  868.     move    P61_etab2(pc,d0),d0
  869.     jmp    P61_etab2(pc,d0)
  870.  
  871. P61_etab2
  872.     dc    P61_contfxdone-P61_etab2
  873.  
  874.     ifne    P61_fsu
  875.     dc    P61_fineup2-P61_etab2
  876.     else
  877.     dc    P61_contfxdone-P61_etab2
  878.     endc
  879.  
  880.     ifne    P61_fsd
  881.     dc    P61_finedwn2-P61_etab2
  882.     else
  883.     dc    P61_contfxdone-P61_etab2
  884.     endc
  885.  
  886.     dc    P61_contfxdone-P61_etab2
  887.     dc    P61_contfxdone-P61_etab2
  888.  
  889.     dc    P61_contfxdone-P61_etab2
  890.     dc    P61_contfxdone-P61_etab2
  891.  
  892.     dc    P61_contfxdone-P61_etab2
  893.     dc    P61_contfxdone-P61_etab2
  894.  
  895.     ifne    P61_rt
  896.     dc    P61_retrig-P61_etab2
  897.     else
  898.     dc    P61_contfxdone-P61_etab2
  899.     endc
  900.  
  901.     ifne    P61_fvu
  902.     dc    P61_finevup2-P61_etab2
  903.     else
  904.     dc    P61_contfxdone-P61_etab2
  905.     endc
  906.  
  907.     ifne    P61_fvd
  908.     dc    P61_finevdwn2-P61_etab2
  909.     else
  910.     dc    P61_contfxdone-P61_etab2
  911.     endc
  912.  
  913.     ifne    P61_nc
  914.     dc    P61_notecut-P61_etab2
  915.     else
  916.     dc    P61_contfxdone-P61_etab2
  917.     endc
  918.  
  919.     ifne    P61_nd
  920.     dc    P61_notedelay-P61_etab2
  921.     else
  922.     dc    P61_contfxdone-P61_etab2
  923.     endc
  924.  
  925.     dc    P61_contfxdone-P61_etab2
  926.     dc    P61_contfxdone-P61_etab2
  927.     endc
  928.  
  929.     ifne    P61_fsu
  930. P61_fineup2
  931.     tst    (a3)
  932.     bne    P61_contfxdone
  933.     moveq    #$f,d0
  934.     and.b    P61_Info(a5),d0
  935.     sub    d0,P61_Period(a5)
  936.     moveq    #113,d0
  937.     cmp    P61_Period(a5),d0
  938.     ble.b    .jup
  939.     move    d0,P61_Period(a5)
  940. .jup    move    P61_Period(a5),6(a4)
  941.     bra    P61_contfxdone
  942.     endc
  943.  
  944.     ifne    P61_fsd
  945. P61_finedwn2
  946.     tst    (a3)
  947.     bne    P61_contfxdone
  948.     moveq    #$f,d0
  949.     and.b    P61_Info(a5),d0
  950.     add    d0,P61_Period(a5)
  951.     cmp    #856,P61_Period(a5)
  952.     ble.b    .jup
  953.     move    #856,P61_Period(a5)
  954. .jup    move    P61_Period(a5),6(a4)
  955.     bra    P61_contfxdone
  956.     endc
  957.  
  958.     ifne    P61_fvu
  959. P61_finevup2
  960.     tst    (a3)
  961.     bne    P61_contfxdone
  962.     moveq    #$f,d0
  963.     and.b    P61_Info(a5),d0
  964.     add    d0,P61_Volume(a5)
  965.     moveq    #64,d0
  966.     cmp    P61_Volume(a5),d0
  967.     bge.b    .jup
  968.     move    d0,P61_Volume(a5)
  969. .jup    move    P61_Volume(a5),8(a4)
  970.     bra    P61_contfxdone
  971.     endc
  972.  
  973.     ifne    P61_fvd
  974. P61_finevdwn2
  975.     tst    (a3)
  976.     bne    P61_contfxdone
  977.     moveq    #$f,d0
  978.     and.b    P61_Info(a5),d0
  979.     sub    d0,P61_Volume(a5)
  980.     bpl.b    .jup
  981.     clr    P61_Volume(a5)
  982. .jup    move    P61_Volume(a5),8(a4)
  983.     bra    P61_contfxdone
  984.     endc
  985.  
  986.     ifne    P61_nc
  987. P61_notecut
  988.     moveq    #$f,d0
  989.     and.b    P61_Info(a5),d0
  990.     cmp    (a3),d0
  991.     bne    P61_contfxdone
  992.     ifeq    fade
  993.     clr    8(a4)
  994.     else
  995.     clr    P61_Shadow(a5)
  996.     endc
  997.     clr    P61_Volume(a5)
  998.     bra    P61_contfxdone
  999.     endc
  1000.  
  1001.     ifne    P61_nd
  1002. P61_notedelay
  1003.     moveq    #$f,d0
  1004.     and.b    P61_Info(a5),d0
  1005.     cmp    (a3),d0
  1006.     bne    P61_contfxdone
  1007.  
  1008.     moveq    #$7e,d0
  1009.     and.b    (a5),d0
  1010.     beq    P61_contfxdone
  1011.     move    P61_DMABit(a5),d0
  1012.     move    d0,$96(a6)
  1013.     or    d0,P61_dma-P61_cn(a3)
  1014.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1015.     move.l    (a1)+,(a4)+            ;Pointer
  1016.     move    (a1),(a4)+            ;Length
  1017.     move    P61_Period(a5),(a4)
  1018.     subq.l    #6,a4
  1019.  
  1020.     ifeq    system
  1021.     lea    P61_dmason(pc),a1
  1022.     move.l    P61_vektori(pc),a0
  1023.     move.l    a1,(a0)
  1024.     move.b    #$f0,$bfd600
  1025.     move.b    #$01,$bfd700
  1026.     move.b    #$19,$bfdf00
  1027.     else
  1028.     move    #1,P61_server-P61_cn(a3)
  1029.     move.l    P61_craddr+4(pc),a1
  1030.     move.b    #$f0,(a1)
  1031.     move.b    #1,$100(a1)
  1032.     endc
  1033.     bra    P61_contfxdone
  1034.     endc
  1035.  
  1036.     ifne    P61_rt
  1037. P61_retrig
  1038.     subq    #1,P61_RetrigCount(a5)
  1039.     bne    P61_contfxdone
  1040.     move    P61_DMABit(a5),d0
  1041.     move    d0,$96(a6)
  1042.     or    d0,P61_dma-P61_cn(a3)
  1043.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1044.     move.l    (a1)+,(a4)            ;Pointer
  1045.     move    (a1),4(a4)            ;Length
  1046.  
  1047.     ifeq    system
  1048.     lea    P61_dmason(pc),a1
  1049.     move.l    P61_vektori(pc),a0
  1050.     move.l    a1,(a0)
  1051.     move.b    #$f0,$bfd600
  1052.     move.b    #$01,$bfd700
  1053.     move.b    #$19,$bfdf00
  1054.     else
  1055.     move    #1,P61_server-P61_cn(a3)
  1056.     move.l    P61_craddr+4(pc),a1
  1057.     move.b    #$f0,(a1)
  1058.     move.b    #1,$100(a1)
  1059.     endc
  1060.  
  1061.     moveq    #$f,d0
  1062.     and.b    P61_Info(a5),d0
  1063.     move    d0,P61_RetrigCount(a5)
  1064.     bra    P61_contfxdone
  1065.     endc
  1066.  
  1067.     ifne    P61_arp
  1068. P61_arplist
  1069.  dc.b 0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1,-1,0,1
  1070.  
  1071. P61_arpeggio
  1072.     move    (a3),d0
  1073.     move.b    P61_arplist(pc,d0),d0
  1074.     beq.b    .arp0
  1075.     bmi.b    .arp1
  1076.  
  1077.     move.b    P61_Info(a5),d0
  1078.     lsr    #4,d0
  1079.     bra.b    .arp3
  1080.  
  1081. .arp0    move    P61_Note(a5),d0
  1082.     move    P61_periods(pc,d0),6(a4)
  1083.     bra    P61_contfxdone
  1084.  
  1085. .arp1    moveq    #$f,d0
  1086.     and.b    P61_Info(a5),d0
  1087.  
  1088. .arp3    add    d0,d0
  1089.     add    P61_Note(a5),d0
  1090.     move    P61_periods(pc,d0),6(a4)
  1091.     bra    P61_contfxdone
  1092.     endc
  1093.  
  1094. P61_periods
  1095.     ifne    P61_ft
  1096.     incbin    "data/p61a.periods"
  1097.     else
  1098.     incbin    "data/p61a.periods.nft"
  1099.     endc
  1100.  
  1101.     ifne    P61_vs
  1102. P61_volslide
  1103.     move.b    P61_Info(a5),d0
  1104.     sub.b    d0,P61_Volume+1(a5)
  1105.     bpl.b    .test
  1106.     clr    P61_Volume(a5)
  1107.     ifeq    fade
  1108.     clr    8(a4)
  1109.     else
  1110.     clr    P61_Shadow(a5)
  1111.     endc
  1112.     bra    P61_contfxdone
  1113. .test    moveq    #64,d0
  1114.     cmp    P61_Volume(a5),d0
  1115.     bge.b    .ncs
  1116.     move    d0,P61_Volume(a5)
  1117.     ifeq    fade
  1118.     move    d0,8(a4)
  1119.     else
  1120.     move    d0,P61_Shadow(a5)
  1121.     endc
  1122.     bra.b    P61_contfxdone
  1123. .ncs
  1124.     ifeq    fade
  1125.     move    P61_Volume(a5),8(a4)
  1126.     else
  1127.     move    P61_Volume(a5),P61_Shadow(a5)
  1128.     endc
  1129.     bra.b    P61_contfxdone
  1130.     endc
  1131.  
  1132.     ifne    P61_tpvs
  1133. P61_tpochvslide
  1134.     move.b    P61_Info(a5),d0
  1135.     sub.b    d0,P61_Volume+1(a5)
  1136.     bpl.b    .test
  1137.     clr    P61_Volume(a5)
  1138.     ifeq    fade
  1139.     clr    8(a4)
  1140.     else
  1141.     clr    P61_Shadow(a5)
  1142.     endc
  1143.     bra.b    P61_toneport
  1144. .test    moveq    #64,d0
  1145.     cmp    P61_Volume(a5),d0
  1146.     bge.b    .ncs
  1147.     move    d0,P61_Volume(a5)
  1148. .ncs
  1149.     ifeq    fade
  1150.     move    P61_Volume(a5),8(a4)
  1151.     else
  1152.     move    P61_Volume(a5),P61_Shadow(a5)
  1153.     endc
  1154.     endc
  1155.  
  1156.     ifne    P61_tp
  1157. P61_toneport
  1158.     move    P61_ToPeriod(a5),d0
  1159.     beq.b    P61_contfxdone
  1160.     move    P61_TPSpeed(a5),d1
  1161.     cmp    P61_Period(a5),d0
  1162.     blt.b    .topoup
  1163.  
  1164.     add    d1,P61_Period(a5)
  1165.     cmp    P61_Period(a5),d0
  1166.     bgt.b    .setper
  1167.     move    d0,P61_Period(a5)
  1168.     clr    P61_ToPeriod(a5)
  1169.     move    d0,6(a4)
  1170.     bra.b    P61_contfxdone
  1171.  
  1172. .topoup
  1173.     sub    d1,P61_Period(a5)
  1174.     cmp    P61_Period(a5),d0
  1175.     blt.b    .setper
  1176.     move    d0,P61_Period(a5)
  1177.     clr    P61_ToPeriod(a5)
  1178. .setper
  1179.     move    P61_Period(a5),6(a4)
  1180.     else
  1181.     nop
  1182.     endc
  1183.  
  1184. P61_contfxdone
  1185.     ifne    P61_il
  1186.     bsr    P61_funk2
  1187.     endc
  1188.  
  1189.     add.l    d6,a5
  1190.     add.l    d7,a4
  1191.     dbf    d5,P61_lopas
  1192.  
  1193.     cmp    P61_speed2(pc),d4
  1194.     beq.b    P61_preplay
  1195.     rts
  1196.  
  1197.     ifne    P61_pu
  1198. P61_portup
  1199.     moveq    #0,D0
  1200.     move.b    P61_Info(a5),d0
  1201.     sub    d0,P61_Period(a5)
  1202.     moveq    #113,d0
  1203.     cmp    P61_Period(a5),d0
  1204.     ble.b    .skip
  1205.     move    d0,P61_Period(a5)
  1206.     move    d0,6(a4)
  1207.     bra.b    P61_contfxdone
  1208. .skip
  1209.     move    P61_Period(a5),6(a4)
  1210.     bra.b    P61_contfxdone
  1211.     endc
  1212.  
  1213.     ifne    P61_pd
  1214. P61_portdwn
  1215.     moveq    #0,d0
  1216.     move.b    P61_Info(a5),d0
  1217.     add    d0,P61_Period(a5)
  1218.     cmp    #856,P61_Period(a5)
  1219.     ble.b    .skip
  1220.     move    #856,d0
  1221.     move    d0,P61_Period(a5)
  1222.     move    d0,6(a4)
  1223.     bra.b    P61_contfxdone
  1224. .skip
  1225.     move    P61_Period(a5),6(a4)
  1226.     bra.b    P61_contfxdone
  1227.     endc
  1228.  
  1229.     ifne    P61_pde
  1230. P61_return
  1231.     rts
  1232.  
  1233. P61_preplay
  1234.     tst    P61_pdflag-P61_cn(a3)
  1235.     bne.b    P61_return
  1236.     else
  1237. P61_preplay
  1238.     endc
  1239.  
  1240.     lea    P61_temp0(pc),a5
  1241.     lea    P61_samples-16(pc),a0
  1242.  
  1243.     moveq    #channels-1,d5
  1244. P61_loaps
  1245.     ifne    P61_pl
  1246.     lea    P61_TData(a5),a1
  1247.     move    2(a5),(a1)+
  1248.     move.l    P61_ChaPos(a5),(a1)+
  1249.     move.l    P61_TempPos(a5),(a1)+
  1250.     move    P61_TempLen(a5),(a1)
  1251.     endc
  1252.  
  1253.     move.b    P61_Pack(a5),d0
  1254.     and.b    #$3f,d0
  1255.     beq.b    P61_takeone
  1256.  
  1257.     tst.b    P61_Pack(a5)
  1258.     bmi.b    .keepsame
  1259.  
  1260.     subq.b    #1,P61_Pack(a5)
  1261.     clr    P61_OnOff(a5)            ; Empty row
  1262.     add.l    d6,a5
  1263.     dbf    d5,P61_loaps
  1264.     rts
  1265.  
  1266. .keepsame
  1267.     subq.b    #1,P61_Pack(a5)
  1268.     bra    P61_dko
  1269.  
  1270. P61_takeone
  1271.     tst.b    P61_TempLen+1(a5)
  1272.     beq.b    P61_takenorm
  1273.  
  1274.     subq.b    #1,P61_TempLen+1(a5)
  1275.     move.l    P61_TempPos(a5),a2
  1276.  
  1277. P61_jedi
  1278.     move.b    (a2)+,d0
  1279.     moveq    #%01100000,d1
  1280.     and.b    d0,d1
  1281.     cmp.b    #%01100000,d1
  1282.     bne.b    .all
  1283.  
  1284.     moveq    #%01110000,d1
  1285.     and.b    d0,d1
  1286.     cmp.b    #%01110000,d1
  1287.     bne.b    .cmd
  1288.  
  1289.     moveq    #%01111000,d1
  1290.     and.b    d0,d1
  1291.     cmp.b    #%01111000,d1
  1292.     bne.b    .note
  1293.  
  1294. .empty    clr    P61_OnOff(a5)            ; Empty row
  1295.     clr    (a5)+
  1296.     clr.b    (a5)+
  1297.     tst.b    d0
  1298.     bpl.b    .ex
  1299.     move.b    (a2)+,(a5)            ; Compression info
  1300.     bra.b    .ex
  1301.  
  1302. .all    move.b    d0,(a5)+
  1303.     ifeq    opt020
  1304.     move.b    (a2)+,(a5)+
  1305.     move.b    (a2)+,(a5)+
  1306.     else
  1307.     move    (a2)+,(a5)+
  1308.     endc
  1309.     tst.b    d0
  1310.     bpl.b    .ex
  1311.     move.b    (a2)+,(a5)            ; Compression info
  1312.     bra.b    .ex
  1313.  
  1314. .cmd    moveq    #$f,d1
  1315.     and    d0,d1
  1316.     move    d1,(a5)+            ; cmd
  1317.     move.b    (a2)+,(a5)+            ; info
  1318.     tst.b    d0
  1319.     bpl.b    .ex
  1320.     move.b    (a2)+,(a5)            ; Compression info
  1321.     bra.b    .ex
  1322.  
  1323. .note    moveq    #7,d1
  1324.     and    d0,d1
  1325.     lsl    #8,d1
  1326.     move.b    (a2)+,d1
  1327.     lsl    #4,d1
  1328.     move    d1,(a5)+
  1329.     clr.b    (a5)+    
  1330.     tst.b    d0
  1331.     bpl.b    .ex
  1332.     move.b    (a2)+,(a5)            ; Compression info
  1333. .ex    subq.l    #3,a5
  1334.     move.l    a2,P61_TempPos(a5)
  1335.     bra    P61_dko
  1336.  
  1337.  
  1338. P61_takenorm
  1339.     move.l    P61_ChaPos(a5),a2
  1340.  
  1341.     move.b    (a2)+,d0
  1342.     moveq    #%01100000,d1
  1343.     and.b    d0,d1
  1344.     cmp.b    #%01100000,d1
  1345.     bne.b    .all
  1346.  
  1347.     moveq    #%01110000,d1
  1348.     and.b    d0,d1
  1349.     cmp.b    #%01110000,d1
  1350.     bne.b    .cmd
  1351.  
  1352.     moveq    #%01111000,d1
  1353.     and.b    d0,d1
  1354.     cmp.b    #%01111000,d1
  1355.     bne.b    .note
  1356.  
  1357. .empty    clr    P61_OnOff(a5)            ; Empty row
  1358.     clr    (a5)+
  1359.     clr.b    (a5)+
  1360.     tst.b    d0
  1361.     bpl.b    .proccomp
  1362.     move.b    (a2)+,(a5)            ; Compression info
  1363.     bra.b    .proccomp
  1364.  
  1365.  
  1366. .all    move.b    d0,(a5)+
  1367.     ifeq    opt020
  1368.     move.b    (a2)+,(a5)+
  1369.     move.b    (a2)+,(a5)+
  1370.     else
  1371.     move    (a2)+,(a5)+
  1372.     endc
  1373.     tst.b    d0
  1374.     bpl.b    .proccomp
  1375.     move.b    (a2)+,(a5)            ; Compression info
  1376.     bra.b    .proccomp
  1377.  
  1378. .cmd    moveq    #$f,d1
  1379.     and    d0,d1
  1380.     move    d1,(a5)+            ; cmd
  1381.     move.b    (a2)+,(a5)+            ; info
  1382.     tst.b    d0
  1383.     bpl.b    .proccomp
  1384.     move.b    (a2)+,(a5)            ; Compression info
  1385.     bra.b    .proccomp
  1386.  
  1387. .note    moveq    #7,d1
  1388.     and    d0,d1
  1389.     lsl    #8,d1
  1390.     move.b    (a2)+,d1
  1391.     lsl    #4,d1
  1392.     move    d1,(a5)+
  1393.     clr.b    (a5)+    
  1394.     tst.b    d0
  1395.     bpl.b    .proccomp
  1396.     move.b    (a2)+,(a5)            ; Compression info
  1397.  
  1398. .proccomp
  1399.     subq.l    #3,a5
  1400.     move.l    a2,P61_ChaPos(a5)
  1401.  
  1402.     tst.b    d0
  1403.     bpl.b    P61_dko
  1404.  
  1405.     move.b    3(a5),d0
  1406.     move.b    d0,d1
  1407.     and    #%11000000,d1
  1408.     beq.b    P61_dko                ; Empty datas
  1409.     cmp.b    #%10000000,d1
  1410.     beq.b    P61_dko                ; Same datas
  1411.  
  1412.     clr.b    3(a5)
  1413.     and    #$3f,d0
  1414.     move.b    d0,P61_TempLen+1(a5)
  1415.  
  1416.     cmp.b    #%11000000,d1
  1417.     beq.b    .bit16                ; 16-bit
  1418.  
  1419.     moveq    #0,d0                ; 8-bit
  1420.     move.b    (a2)+,d0
  1421.     move.l    a2,P61_ChaPos(a5)
  1422.     sub.l    d0,a2
  1423.     bra    P61_jedi
  1424.  
  1425. .bit16    moveq    #0,d0
  1426.     ifeq    opt020
  1427.     move.b    (a2)+,d0
  1428.     lsl    #8,d0
  1429.     move.b    (a2)+,d0
  1430.     else
  1431.     move    (a2)+,d0
  1432.     endc
  1433.  
  1434.     move.l    a2,P61_ChaPos(a5)
  1435.     sub.l    d0,a2
  1436.     bra    P61_jedi
  1437.  
  1438.  
  1439. P61_dko    st    P61_OnOff(a5)
  1440.     move    (a5),d0
  1441.     and    #$1f0,d0
  1442.     beq.b    .koto
  1443.     lea    (a0,d0),a1
  1444.     move.l    a1,P61_Sample(a5)
  1445.     ifne    P61_ft
  1446.     move.l    P61_SampleVolume(a1),P61_Volume(a5)
  1447.     else
  1448.     move    P61_SampleVolume(a1),P61_Volume(a5)
  1449.     endc
  1450.     ifne    P61_il
  1451.     move.l    P61_RepeatOffset(a1),P61_Wave(a5)
  1452.     endc
  1453.     ifne    P61_sof
  1454.     clr    P61_Offset(a5)
  1455.     endc
  1456.  
  1457. .koto    add.l    d6,a5
  1458.     dbf    d5,P61_loaps
  1459.     rts
  1460.  
  1461. P61_playtime
  1462.     clr    (a3)
  1463.  
  1464.     ifne    P61_pde
  1465.     tst    P61_pdelay-P61_cn(a3)
  1466.     beq.b    .djdj
  1467.     subq    #1,P61_pdelay-P61_cn(a3)
  1468.     bne    P61_delay
  1469.     tst    P61_speedis1-P61_cn(a3)
  1470.     bne    P61_delay
  1471.     clr    P61_pdflag-P61_cn(a3)
  1472.     bra    P61_delay
  1473. .djdj
  1474.     clr    P61_pdflag-P61_cn(a3)
  1475.     endc
  1476.  
  1477.     tst    P61_speedis1-P61_cn(a3)
  1478.     beq.b    .mo
  1479.     bsr    P61_preplay
  1480.  
  1481. .mo    lea    P61_temp0(pc),a5
  1482.     lea    $a0(a6),a4
  1483.  
  1484.     ifeq    system
  1485.     lea    P61_dmason(pc),a1
  1486.     move.l    P61_vektori(pc),a0
  1487.     move.l    a1,(a0)
  1488.     move.b    #$f0,$bfd600
  1489.     move.b    #$01,$bfd700
  1490.     move.b    #$19,$bfdf00
  1491.     else
  1492.     move    #1,P61_server-P61_cn(a3)
  1493.     move.l    P61_craddr+4(pc),a1
  1494.     move.b    #$f0,(a1)
  1495.     move.b    #1,$100(a1)
  1496.     endc
  1497.  
  1498.     lea    P61_periods(pc),a2
  1499.  
  1500.     moveq    #0,d4
  1501.     moveq    #channels-1,d5
  1502. P61_los    tst    P61_OnOff(a5)
  1503.     beq.b    P61_nocha
  1504.  
  1505.     moveq    #$f,d0
  1506.     and    (a5),d0
  1507.     lea    P61_jtab(pc),a1
  1508.     add    d0,d0
  1509.     add.l    d0,a1
  1510.     add    (a1),a1
  1511.     jmp    (a1)
  1512.  
  1513. P61_fxdone
  1514.     moveq    #$7e,d0
  1515.     and.b    (a5),d0
  1516.     beq.b    P61_nocha
  1517.     ifne    P61_vib
  1518.     clr.b    P61_VibPos(a5)
  1519.     endc
  1520.     ifne    P61_tre
  1521.     clr.b    P61_TrePos(a5)
  1522.     endc
  1523.  
  1524.      ifne    P61_ft
  1525.     add    P61_Fine(a5),d0
  1526.     endc
  1527.     move    d0,P61_Note(a5)
  1528.     move    (a2,d0),P61_Period(a5)
  1529.  
  1530. P61_zample
  1531.     ifne    P61_sof
  1532.     tst    P61_Offset(a5)
  1533.     bne    P61_pek
  1534.     endc
  1535.  
  1536.     or    P61_DMABit(a5),d4
  1537.     move    d4,$96(a6)
  1538.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1539.     move.l    (a1)+,(a4)            ;Pointer
  1540.     move    (a1),4(a4)            ;Length
  1541.  
  1542. P61_nocha
  1543.     ifeq    fade
  1544.     move.l    P61_Period(a5),6(a4)
  1545.     else
  1546.     move    P61_Period(a5),6(a4)
  1547.     move    P61_Volume(a5),P61_Shadow(a5)
  1548.     endc
  1549.  
  1550. P61_skip
  1551.     ifne    P61_il
  1552.     bsr    P61_funk2
  1553.     endc
  1554.  
  1555.     add.l    d6,a5
  1556.     add.l    d7,a4
  1557.     dbf    d5,P61_los
  1558.  
  1559.     move.b    d4,P61_dma+1-P61_cn(a3)
  1560.  
  1561.     ifne    P61_pl
  1562.     tst.b    P61_plflag+1-P61_cn(a3)
  1563.     beq.b    P61_ohittaa
  1564.  
  1565.     lea    P61_temp0(pc),a1
  1566.     lea    P61_looppos(pc),a0
  1567.     moveq    #channels-1,d0
  1568. .talt    move.b    1(a0),3(a1)
  1569.     addq.l    #2,a0
  1570.     move.l    (a0)+,P61_ChaPos(a1)
  1571.     move.l    (a0)+,P61_TempPos(a1)
  1572.     move    (a0)+,P61_TempLen(a1)
  1573.     add.l    d6,a1
  1574.     dbf    d0,.talt
  1575.  
  1576.     move    P61_plrowpos(pc),P61_rowpos-P61_cn(a3)
  1577.     clr.b    P61_plflag+1-P61_cn(a3)
  1578.     moveq    #63,d0
  1579.     sub    P61_rowpos-P61_cn(a3),d0
  1580.     move    d0,P61_CRow-P61_cn(a3)
  1581.     rts
  1582.     endc
  1583.  
  1584. P61_ohittaa
  1585.     subq    #1,P61_rowpos-P61_cn(a3)
  1586.     bmi.b    P61_nextpattern
  1587.     moveq    #63,d0
  1588.     sub    P61_rowpos-P61_cn(a3),d0
  1589.     move    d0,P61_CRow-P61_cn(a3)
  1590.     rts
  1591.  
  1592. P61_nextpattern
  1593.     ifne    P61_pl
  1594.     clr    P61_plflag-P61_cn(a3)
  1595.     endc
  1596.     move.l    P61_patternbase(pc),a4
  1597.     moveq    #63,d0
  1598.     move    d0,P61_rowpos-P61_cn(a3)
  1599.     clr    P61_CRow-P61_cn(a3)
  1600.     move.l    P61_spos(pc),a1
  1601.     addq    #1,P61_Pos-P61_cn(a3)
  1602.     move.b    (a1)+,d0
  1603.     bpl.b    P61_dk
  1604.     move.l    P61_possibase(pc),a1
  1605.     move.b    (a1)+,d0
  1606.     clr    P61_Pos-P61_cn(a3)
  1607.     move.w    #-2,P61_E8-P61_cn(a3)        ;songend
  1608. P61_dk    move.l    a1,P61_spos-P61_cn(a3)
  1609.     move    d0,P61_Patt-P61_cn(a3)
  1610.     lsl    #3,d0
  1611.     move.l    P61_positionbase(pc),a1
  1612.     add.l    d0,a1
  1613.  
  1614.     move    (a1)+,d0
  1615.     lea    (a4,d0.l),a2
  1616.     move.l    a2,P61_ChaPos+P61_temp0-P61_cn(a3)
  1617.     move    (a1)+,d0
  1618.     lea    (a4,d0.l),a2
  1619.     move.l    a2,P61_ChaPos+P61_temp1-P61_cn(a3)
  1620.     move    (a1)+,d0
  1621.     lea    (a4,d0.l),a2
  1622.     move.l    a2,P61_ChaPos+P61_temp2-P61_cn(a3)
  1623.     move    (a1),d0
  1624.     add.l    d0,a4
  1625.     move.l    a4,P61_ChaPos+P61_temp3-P61_cn(a3)
  1626.     rts
  1627.  
  1628.     ifne    P61_tp
  1629. P61_settoneport
  1630.     move.b    P61_Info(a5),d0
  1631.     beq.b    P61_toponochange
  1632.     move.b    d0,P61_TPSpeed+1(a5)
  1633. P61_toponochange
  1634.     moveq    #$7e,d0
  1635.     and.b    (a5),d0
  1636.     beq    P61_nocha
  1637.     add    P61_Fine(a5),d0
  1638.     move    d0,P61_Note(a5)
  1639.     move    (a2,d0),P61_ToPeriod(a5)
  1640.     bra    P61_nocha
  1641.     endc
  1642.  
  1643.     ifne    P61_sof
  1644. P61_sampleoffse
  1645.     moveq    #0,d1
  1646.     move    #$ff00,d1
  1647.     and    2(a5),d1
  1648.     bne.b    .deq
  1649.     move    P61_LOffset(a5),d1
  1650. .deq    move    d1,P61_LOffset(a5)
  1651.     add    d1,P61_Offset(a5)
  1652.  
  1653.     moveq    #$7e,d0
  1654.     and.b    (a5),d0
  1655.     beq    P61_nocha
  1656.  
  1657.     move    P61_Offset(a5),d2
  1658.     add    d1,P61_Offset(a5)        ; THIS IS A PT-FEATURE!
  1659.     move    d2,d1
  1660.  
  1661.     ifne    P61_vib
  1662.     clr.b    P61_VibPos(a5)
  1663.     endc
  1664.     ifne    P61_tre
  1665.     clr.b    P61_TrePos(a5)
  1666.     endc
  1667.  
  1668.     ifne    P61_ft
  1669.     add    P61_Fine(a5),d0
  1670.     endc
  1671.     move    d0,P61_Note(a5)
  1672.     move    (a2,d0),P61_Period(a5)
  1673.     bra.b    P61_hup
  1674.  
  1675. P61_pek    moveq    #0,d1
  1676.     move    P61_Offset(a5),d1
  1677. P61_hup    or    P61_DMABit(a5),d4
  1678.     move    d4,$96(a6)
  1679.     move.l    P61_Sample(a5),a1        ;* Trigger *
  1680.     move.l    (a1)+,d0
  1681.     add.l    d1,d0
  1682.     move.l    d0,(a4)                ;Pointer
  1683.     lsr    #1,d1
  1684.     move    (a1),d0
  1685.     sub    d1,d0
  1686.     bpl.b    P61_offok
  1687.     move.l    -4(a1),(a4)            ;Pointer is over the end
  1688.     moveq    #1,d0
  1689. P61_offok
  1690.     move    d0,4(a4)            ;Length
  1691.     bra    P61_nocha
  1692.     endc
  1693.  
  1694.     ifne    P61_vl
  1695. P61_volum
  1696.     move.b    P61_Info(a5),P61_Volume+1(a5)
  1697.     bra    P61_fxdone
  1698.     endc
  1699.  
  1700.     ifne    P61_pj
  1701. P61_posjmp
  1702.     moveq    #0,d0
  1703.     move.b    P61_Info(a5),d0
  1704.     cmp    P61_slen-P61_cn(a3),d0
  1705.     blo.b    .e
  1706.     moveq    #0,d0
  1707. .e    move    d0,P61_Pos-P61_cn(a3)
  1708.     add.l    P61_possibase(pc),d0
  1709.     move.l    d0,P61_spos-P61_cn(a3)
  1710.     endc
  1711.  
  1712.     ifne    P61_pb
  1713. P61_pattbreak
  1714.     moveq    #64,d0
  1715.     move    d0,P61_rowpos-P61_cn(a3)
  1716.     clr    P61_CRow-P61_cn(a3)
  1717.     move.l    P61_spos(pc),a1
  1718.     move.l    P61_patternbase(pc),a0
  1719.     addq    #1,P61_Pos-P61_cn(a3)
  1720.     move.b    (a1)+,d0
  1721.     bpl.b    P61_dk2
  1722.     move.l    P61_possibase(pc),a1
  1723.     move.b    (a1)+,d0
  1724.     clr    P61_Pos-P61_cn(a3)
  1725. P61_dk2    move.l    a1,P61_spos-P61_cn(a3)
  1726.     move.l    P61_positionbase(pc),a1
  1727.     move    d0,P61_Patt-P61_cn(a3)
  1728.     lsl    #3,d0
  1729.     add.l    d0,a1
  1730.     movem    (a1),d0-d3
  1731.     lea    (a0,d0.l),a1
  1732.     move    d1,d0
  1733.     move.l    a1,P61_ChaPos+P61_temp0-P61_cn(a3)
  1734.     lea    (a0,d0.l),a1
  1735.     move.l    a1,P61_ChaPos+P61_temp1-P61_cn(a3)
  1736.     move    d2,d0
  1737.     lea    (a0,d0.l),a1
  1738.     move.l    a1,P61_ChaPos+P61_temp2-P61_cn(a3)
  1739.     move    d3,d0
  1740.     add.l    d0,a0
  1741.     move.l    a0,P61_ChaPos+P61_temp3-P61_cn(a3)
  1742.     bra    P61_fxdone
  1743.     endc
  1744.  
  1745.     ifne    P61_vib
  1746. P61_vibrato
  1747.     move.b    P61_Info(a5),d0
  1748.     beq    P61_fxdone
  1749.     move.b    d0,d1
  1750.     move.b    P61_VibCmd(a5),d2
  1751.     and.b    #$f,d0
  1752.     beq.b    P61_vibskip
  1753.     and.b    #$f0,d2
  1754.     or.b    d0,d2
  1755. P61_vibskip
  1756.     and.b    #$f0,d1
  1757.     beq.b    P61_vibskip2
  1758.     and.b    #$f,d2
  1759.     or.b    d1,d2
  1760. P61_vibskip2
  1761.     move.b    d2,P61_VibCmd(a5)
  1762.     bra    P61_fxdone
  1763.     endc
  1764.  
  1765.     ifne    P61_tre
  1766. P61_settremo
  1767.     move.b    P61_Info(a5),d0
  1768.     beq    P61_fxdone
  1769.     move.b    d0,d1
  1770.     move.b    P61_TreCmd(a5),d2
  1771.     moveq    #$f,d3
  1772.     and.b    d3,d0
  1773.     beq.b    P61_treskip
  1774.     and.b    #$f0,d2
  1775.     or.b    d0,d2
  1776. P61_treskip
  1777.     and.b    #$f0,d1
  1778.     beq.b    P61_treskip2
  1779.     and.b    d3,d2
  1780.     or.b    d1,d2
  1781. P61_treskip2
  1782.     move.b    d2,P61_TreCmd(a5)
  1783.     bra    P61_fxdone
  1784.     endc
  1785.  
  1786.     ifne    P61_ec
  1787. P61_ecommands
  1788.     move.b    P61_Info(a5),d0
  1789.     and.b    #$f0,d0
  1790.     lsr    #3,d0
  1791.     move    P61_etab(pc,d0),d0
  1792.     jmp    P61_etab(pc,d0)
  1793.  
  1794. P61_etab
  1795.     ifne    P61_fi
  1796.     dc    P61_filter-P61_etab
  1797.     else
  1798.     dc    P61_fxdone-P61_etab
  1799.     endc
  1800.  
  1801.     ifne    P61_fsu
  1802.     dc    P61_fineup-P61_etab
  1803.     else
  1804.     dc    P61_fxdone-P61_etab
  1805.     endc
  1806.  
  1807.     ifne    P61_fsd
  1808.     dc    P61_finedwn-P61_etab
  1809.     else
  1810.     dc    P61_fxdone-P61_etab
  1811.     endc
  1812.  
  1813.     dc    P61_fxdone-P61_etab
  1814.     dc    P61_fxdone-P61_etab
  1815.  
  1816.     ifne    P61_sft
  1817.     dc    P61_setfinetune-P61_etab
  1818.     else
  1819.     dc    P61_fxdone-P61_etab
  1820.     endc
  1821.  
  1822.     ifne    P61_pl
  1823.     dc    P61_patternloop-P61_etab
  1824.     else
  1825.     dc    P61_fxdone-P61_etab
  1826.     endc
  1827.  
  1828.     dc    P61_fxdone-P61_etab
  1829.  
  1830.     ifne    P61_timing
  1831.     dc    P61_sete8-P61_etab
  1832.     else
  1833.     dc    P61_fxdone-P61_etab
  1834.     endc
  1835.  
  1836.     ifne    P61_rt
  1837.     dc    P61_setretrig-P61_etab
  1838.     else
  1839.     dc    P61_fxdone-P61_etab
  1840.     endc
  1841.  
  1842.     ifne    P61_fvu
  1843.     dc    P61_finevup-P61_etab
  1844.     else
  1845.     dc    P61_fxdone-P61_etab
  1846.     endc
  1847.  
  1848.     ifne    P61_fvd
  1849.     dc    P61_finevdwn-P61_etab
  1850.     else
  1851.     dc    P61_fxdone-P61_etab
  1852.     endc
  1853.  
  1854.     dc    P61_fxdone-P61_etab
  1855.  
  1856.     ifne    P61_nd
  1857.     dc    P61_ndelay-P61_etab
  1858.     else
  1859.     dc    P61_fxdone-P61_etab
  1860.     endc
  1861.  
  1862.     ifne    P61_pde
  1863.     dc    P61_pattdelay-P61_etab
  1864.     else
  1865.     dc    P61_fxdone-P61_etab
  1866.     endc
  1867.  
  1868.     ifne    P61_il
  1869.     dc    P61_funk-P61_etab
  1870.     else
  1871.     dc    P61_fxdone-P61_etab
  1872.     endc
  1873.     endc
  1874.  
  1875.     ifne    P61_fi
  1876. P61_filter
  1877.     move.b    P61_Info(a5),d0
  1878.     and.b    #$fd,$bfe001
  1879.     or.b    d0,$bfe001
  1880.     bra    P61_fxdone
  1881.     endc
  1882.  
  1883.     ifne    P61_fsu
  1884. P61_fineup
  1885.     P61_getnote
  1886.  
  1887.     moveq    #$f,d0
  1888.     and.b    P61_Info(a5),d0
  1889.     sub    d0,P61_Period(a5)
  1890.     moveq    #113,d0
  1891.     cmp    P61_Period(a5),d0
  1892.     ble.b    .jup
  1893.     move    d0,P61_Period(a5)
  1894. .jup    moveq    #$7e,d0
  1895.     and.b    (a5),d0
  1896.     bne    P61_zample
  1897.     bra    P61_nocha
  1898.     endc
  1899.  
  1900.     ifne    P61_fsd
  1901. P61_finedwn
  1902.     P61_getnote
  1903.  
  1904.     moveq    #$f,d0
  1905.     and.b    P61_Info(a5),d0
  1906.     add    d0,P61_Period(a5)
  1907.     cmp    #856,P61_Period(a5)
  1908.     ble.b    .jup
  1909.     move    #856,P61_Period(a5)
  1910. .jup    moveq    #$7e,d0
  1911.     and.b    (a5),d0
  1912.     bne    P61_zample
  1913.     bra    P61_nocha
  1914.     endc
  1915.  
  1916.     ifne    P61_sft
  1917. P61_setfinetune
  1918.     moveq    #$f,d0
  1919.     and.b    P61_Info(a5),d0
  1920.     ifeq    opt020
  1921.     add    d0,d0
  1922.     move    P61_mulutab(pc,d0),P61_Fine(a5)
  1923.     else
  1924.     move    P61_mulutab(pc,d0*2),P61_Fine(a5)
  1925.     endc
  1926.     bra    P61_fxdone
  1927.  
  1928. P61_mulutab
  1929.     dc    0,74,148,222,296,370,444,518,592,666,740,814,888,962,1036,1110
  1930.     endc
  1931.  
  1932.     ifne    P61_pl
  1933. P61_patternloop
  1934.     moveq    #$f,d0
  1935.     and.b    P61_Info(a5),d0
  1936.     beq.b    P61_setloop
  1937.  
  1938.     tst.b    P61_plflag-P61_cn(a3)
  1939.     bne.b    P61_noset
  1940.  
  1941.     move    d0,P61_plcount-P61_cn(a3)
  1942.     st.b    P61_plflag-P61_cn(a3)
  1943. P61_noset
  1944.     tst    P61_plcount-P61_cn(a3)
  1945.     bne.b    P61_looppaa
  1946.     clr.b    P61_plflag-P61_cn(a3)
  1947.     bra    P61_fxdone
  1948.     
  1949. P61_looppaa
  1950.     st.b    P61_plflag+1-P61_cn(a3)
  1951.     subq    #1,P61_plcount-P61_cn(a3)
  1952.     bra    P61_fxdone
  1953.  
  1954. P61_setloop
  1955.     tst.b    P61_plflag-P61_cn(a3)
  1956.     bne    P61_fxdone
  1957.     move    P61_rowpos(pc),P61_plrowpos-P61_cn(a3)
  1958.     lea    P61_temp0+P61_TData(pc),a1
  1959.     lea    P61_looppos(pc),a0
  1960.     moveq    #channels-1,d0
  1961. .talt    move.l    (a1)+,(a0)+
  1962.     move.l    (a1)+,(a0)+
  1963.     move.l    (a1),(a0)+
  1964.     subq.l    #8,a1
  1965.     add.l    d6,a1
  1966.     dbf    d0,.talt
  1967.     bra    P61_fxdone
  1968.     endc
  1969.  
  1970.     ifne    P61_fvu
  1971. P61_finevup
  1972.     moveq    #$f,d0
  1973.     and.b    P61_Info(a5),d0
  1974.     add    d0,P61_Volume(a5)
  1975.     moveq    #64,d0
  1976.     cmp    P61_Volume(a5),d0
  1977.     bge    P61_fxdone
  1978.     move    d0,P61_Volume(a5)
  1979.     bra    P61_fxdone
  1980.     endc
  1981.  
  1982.     ifne    P61_fvd
  1983. P61_finevdwn
  1984.     moveq    #$f,d0
  1985.     and.b    P61_Info(a5),d0
  1986.     sub    d0,P61_Volume(a5)
  1987.     bpl    P61_fxdone
  1988.     clr    P61_Volume(a5)
  1989.     bra    P61_fxdone
  1990.     endc
  1991.  
  1992.     ifne    P61_timing
  1993. P61_sete8
  1994.     moveq    #$f,d0
  1995.     and.b    P61_Info(a5),d0
  1996.     move    d0,P61_E8-P61_cn(a3)
  1997.     bra    P61_fxdone
  1998.     endc
  1999.  
  2000.     ifne    P61_rt
  2001. P61_setretrig
  2002.     moveq    #$f,d0
  2003.     and.b    P61_Info(a5),d0
  2004.     move    d0,P61_RetrigCount(a5)
  2005.     bra    P61_fxdone
  2006.     endc
  2007.  
  2008.     ifne    P61_nd
  2009. P61_ndelay
  2010.     moveq    #$7e,d0
  2011.     and.b    (a5),d0
  2012.     beq    P61_skip
  2013.     ifne    P61_vib
  2014.     clr.b    P61_VibPos(a5)
  2015.     endc
  2016.     ifne    P61_tre
  2017.     clr.b    P61_TrePos(a5)
  2018.     endc
  2019.     ifne    P61_ft
  2020.     add    P61_Fine(a5),d0
  2021.     endc
  2022.     move    d0,P61_Note(a5)
  2023.     move    (a2,d0),P61_Period(a5)
  2024.     ifeq    fade
  2025.     move    P61_Volume(a5),8(a4)
  2026.     else
  2027.     move    P61_Volume(a5),P61_Shadow(a5)
  2028.     endc
  2029.     bra    P61_skip
  2030.     endc
  2031.  
  2032.     ifne    P61_pde
  2033. P61_pattdelay
  2034.     moveq    #$f,d0
  2035.     and.b    P61_Info(a5),d0
  2036.     move    d0,P61_pdelay-P61_cn(a3)
  2037.     st    P61_pdflag-P61_cn(a3)
  2038.     bra    P61_fxdone
  2039.     endc
  2040.  
  2041.     ifne    P61_sd
  2042. P61_cspeed
  2043.     moveq    #0,d0
  2044.     move.b    P61_Info(a5),d0
  2045.  
  2046.     ifne    CIA
  2047.     tst    P61_Tempo-P61_cn(a3)
  2048.     beq.b    P61_VBlank
  2049.     cmp.b    #32,d0
  2050.     bhs.b    P61_STempo
  2051.     endc
  2052.  
  2053. P61_VBlank
  2054.     cmp.b    #1,d0
  2055.     beq.b    P61_jkd
  2056.  
  2057.     move.b    d0,P61_speed+1-P61_cn(a3)
  2058.     subq.b    #1,d0
  2059.     move.b    d0,P61_speed2+1-P61_cn(a3)
  2060.     clr    P61_speedis1-P61_cn(a3)
  2061.     bra    P61_fxdone
  2062.  
  2063. P61_jkd    move.b    d0,P61_speed+1-P61_cn(a3)
  2064.     move.b    d0,P61_speed2+1-P61_cn(a3)
  2065.     st    P61_speedis1-P61_cn(a3)
  2066.     bra    P61_fxdone
  2067.  
  2068.  
  2069.     ifne    CIA
  2070. P61_STempo
  2071.     move.l    P61_timer(pc),d1
  2072.     divu    d0,d1
  2073.     move    d1,P61_thi2-P61_cn(a3)
  2074.     sub    #$1f0*2,d1
  2075.     move    d1,P61_thi-P61_cn(a3)
  2076.  
  2077.     ifeq    system
  2078.     move    P61_thi2-P61_cn(a3),d1
  2079.     move.b    d1,$bfd400
  2080.     lsr    #8,d1
  2081.     move.b    d1,$bfd500
  2082.     endc
  2083.  
  2084.     bra    P61_fxdone
  2085.     endc
  2086.     endc
  2087.  
  2088.  
  2089.  
  2090.     ifne    P61_vbvs
  2091. P61_vibochvslide
  2092.     move.b    P61_Info(a5),d0
  2093.     sub.b    d0,P61_Volume+1(a5)
  2094.     bpl.b    P61_test62
  2095.     clr    P61_Volume(a5)
  2096.     ifeq    fade
  2097.     clr    8(a4)
  2098.     else
  2099.     clr    P61_Shadow(a5)
  2100.     endc
  2101.     bra.b    P61_vib2
  2102. P61_test62
  2103.     moveq    #64,d0
  2104.     cmp    P61_Volume(a5),d0
  2105.     bge.b    .ncs2
  2106.     move    d0,P61_Volume(a5)
  2107. .ncs2
  2108.     ifeq    fade
  2109.     move    P61_Volume(a5),8(a4)
  2110.     else
  2111.     move    P61_Volume(a5),P61_Shadow(a5)
  2112.     endc
  2113.     endc
  2114.  
  2115.     ifne    P61_vib
  2116. P61_vib2
  2117.     move    #$f00,d0
  2118.     move    P61_VibCmd(a5),d1
  2119.     and    d1,d0
  2120.     lsr    #3,d0
  2121.  
  2122.     lsr    #2,d1
  2123.     and    #$1f,d1
  2124.     add    d1,d0
  2125.  
  2126.     move    P61_Period(a5),d1
  2127.     moveq    #0,d2
  2128.     move.b    P61_vibtab(pc,d0),d2
  2129.  
  2130.     tst.b    P61_VibPos(a5)
  2131.     bmi.b    .vibneg
  2132.     add    d2,d1
  2133.     bra.b    P61_vib4
  2134.  
  2135. .vibneg    sub    d2,d1
  2136.  
  2137. P61_vib4
  2138.     move    d1,6(a4)
  2139.     move.b    P61_VibCmd(a5),d0
  2140.     lsr.b    #2,d0
  2141.     and    #$3c,d0
  2142.     add.b    d0,P61_VibPos(a5)
  2143.     bra    P61_contfxdone
  2144.     endc
  2145.  
  2146.     ifne    P61_tre
  2147. P61_tremo
  2148.     move    #$f00,d0
  2149.     move    P61_TreCmd(a5),d1
  2150.     and    d1,d0
  2151.     lsr    #3,d0
  2152.     
  2153.     lsr    #2,d1
  2154.     and    #$1f,d1
  2155.     add    d1,d0
  2156.  
  2157.     move    P61_Volume(a5),d1
  2158.     moveq    #0,d2
  2159.     move.b    P61_vibtab(pc,d0),d2
  2160.  
  2161.     tst.b    P61_TrePos(a5)
  2162.     bmi.b    .treneg
  2163.     add    d2,d1
  2164.     cmp    #64,d1
  2165.     ble.b    P61_tre4
  2166.     moveq    #64,d1
  2167.     bra.b    P61_tre4
  2168.  
  2169. .treneg    sub    d2,d1
  2170.     bpl.b    P61_tre4
  2171.     moveq    #0,d1
  2172. P61_tre4
  2173.     ifeq    fade
  2174.     move    d1,8(a4)
  2175.     else
  2176.     move    d1,P61_Shadow(a5)
  2177.     endc
  2178.  
  2179.     move.b    P61_TreCmd(a5),d0
  2180.     lsr.b    #2,d0
  2181.     and    #$3c,d0
  2182.     add.b    d0,P61_TrePos(a5)
  2183.     bra    P61_contfxdone
  2184.     endc
  2185.  
  2186.     ifne    P61_vib!P61_tre
  2187. P61_vibtab
  2188.     incbin    "data/p61a.vibtab"
  2189.     endc
  2190.  
  2191.     ifne    P61_il
  2192. P61_funk
  2193.     moveq    #$f,d0
  2194.     and.b    P61_Info(a5),d0
  2195.     move.b    d0,P61_Funkspd(a5)
  2196.     bra    P61_fxdone
  2197.  
  2198. P61_funk2
  2199.     moveq    #0,d0
  2200.     move.b    P61_Funkspd(a5),d0
  2201.     beq.b    P61_funkend
  2202.     move.b    P61_FunkTable(pc,d0),d0
  2203.     add.b    d0,P61_Funkoff(a5)
  2204.     bpl.b    P61_funkend
  2205.     clr.b    P61_Funkoff(a5)
  2206.  
  2207.     move.l    P61_Sample(a5),a1
  2208.     move.l    P61_RepeatOffset(a1),d1
  2209.     move    P61_RepeatLength(a1),d0
  2210.     add.l    d0,d0
  2211.     add.l    d1,d0
  2212.     move.l    P61_Wave(a5),a0
  2213.     addq.l    #1,a0
  2214.     cmp.l    d0,a0
  2215.     blo.b    P61_funkok
  2216.     move.l    d1,a0
  2217. P61_funkok
  2218.     move.l    a0,P61_Wave(a5)
  2219.     not.b    (a0)
  2220. P61_funkend
  2221.     rts
  2222.  
  2223. P61_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  2224.     endc
  2225.  
  2226. P61_jtab
  2227.     dc    P61_fxdone-*
  2228.     dc    P61_fxdone-*
  2229.     dc    P61_fxdone-*
  2230.  
  2231.     ifne    P61_tp
  2232.     dc    P61_settoneport-*
  2233.     else
  2234.     dc    P61_fxdone-*
  2235.     endc
  2236.  
  2237.     ifne    P61_vib
  2238.     dc    P61_vibrato-*
  2239.     else
  2240.     dc    P61_fxdone-*
  2241.     endc
  2242.  
  2243.     ifne    P61_tpvs
  2244.     dc    P61_toponochange-*
  2245.     else
  2246.     dc    P61_fxdone-*
  2247.     endc
  2248.  
  2249.     dc    P61_fxdone-*
  2250.  
  2251.     ifne    P61_tre
  2252.     dc    P61_settremo-*
  2253.     else
  2254.     dc    P61_fxdone-*
  2255.     endc
  2256.  
  2257.     dc    P61_fxdone-*
  2258.  
  2259.     ifne    P61_sof
  2260.     dc    P61_sampleoffse-*
  2261.     else
  2262.     dc    P61_fxdone-*
  2263.     endc
  2264.     dc    P61_fxdone-*
  2265.  
  2266.     ifne    P61_pj
  2267.     dc    P61_posjmp-*
  2268.     else
  2269.     dc    P61_fxdone-*
  2270.     endc
  2271.  
  2272.     ifne    P61_vl
  2273.     dc    P61_volum-*
  2274.     else
  2275.     dc    P61_fxdone-*
  2276.     endc
  2277.  
  2278.     ifne    P61_pb
  2279.     dc    P61_pattbreak-*
  2280.     else
  2281.     dc    P61_fxdone-*
  2282.     endc
  2283.  
  2284.     ifne    P61_ec
  2285.     dc    P61_ecommands-*
  2286.     else
  2287.     dc    P61_fxdone-*
  2288.     endc
  2289.     
  2290.     ifne    P61_sd
  2291.     dc    P61_cspeed-*
  2292.     else
  2293.     dc    P61_fxdone-*
  2294.     endc
  2295.  
  2296.  
  2297. P61_dmason
  2298.     ifeq    system
  2299.     tst.b    $bfdd00
  2300.     move    #$2000,$dff09c
  2301.     move.b    #$19,$bfdf00
  2302.     move.l    a0,-(sp)
  2303.     move.l    P61_vektori(pc),a0
  2304.     move.l    P61_intaddr(pc),(a0)
  2305.     move.l    (sp)+,a0
  2306.     move    P61_dma(pc),$dff096
  2307.     nop
  2308.     rte
  2309.  
  2310.     else
  2311.  
  2312.     move    P61_dma(pc),$96(a6)
  2313.     lea    P61_server(pc),a3
  2314.     addq    #1,(a3)
  2315.     move.l    P61_craddr(pc),a0
  2316.     move.b    #$19,(a0)
  2317.     bra    P61_ohi
  2318.     endc
  2319.  
  2320.  
  2321. P61_setrepeat
  2322.     ifeq    system
  2323.     tst.b    $bfdd00
  2324.     movem.l    a0/a1,-(sp)
  2325.     lea    $dff0a0,a1
  2326.     move    #$2000,-4(a1)
  2327.     else
  2328.     lea    $a0(a6),a1
  2329.     endc
  2330.  
  2331.     move.l    P61_Sample+P61_temp0(pc),a0
  2332.     addq.l    #6,a0
  2333.     move.l    (a0)+,(a1)+
  2334.     move    (a0),(a1)
  2335.  
  2336.     ifgt    channels-1
  2337.     move.l    P61_Sample+P61_temp1(pc),a0
  2338.     addq.l    #6,a0
  2339.     move.l    (a0)+,12(a1)
  2340.     move    (a0),16(a1)
  2341.     endc
  2342.     
  2343.     ifgt    channels-2
  2344.     move.l    P61_Sample+P61_temp2(pc),a0
  2345.     addq.l    #6,a0
  2346.     move.l    (a0)+,28(a1)
  2347.     move    (a0),32(a1)
  2348.     endc
  2349.  
  2350.     ifgt    channels-3
  2351.     move.l    P61_Sample+P61_temp3(pc),a0
  2352.     addq.l    #6,a0
  2353.     move.l    (a0)+,44(a1)
  2354.     move    (a0),48(a1)
  2355.     endc
  2356.  
  2357.     ifne    system
  2358.     ifne    CIA
  2359.     lea    P61_server(pc),a3
  2360.     clr    (a3)
  2361.     move.l    P61_craddr+4(pc),a0
  2362.     move.b    P61_tlo(pc),(a0)
  2363.     move.b    P61_thi(pc),$100(a0)
  2364.     endc
  2365.     bra    P61_ohi
  2366.     endc
  2367.  
  2368.     ifeq    system
  2369.     ifne    CIA
  2370.     move.l    P61_vektori(pc),a0
  2371.     move.l    P61_tintti(pc),(a0)
  2372.     endc
  2373.     movem.l    (sp)+,a0/a1
  2374.     nop
  2375.     rte
  2376.     endc
  2377.  
  2378. P61_temp0    dcb.b    Channel_Block_SIZE-2
  2379.         dc    1
  2380.  
  2381. P61_temp1    dcb.b    Channel_Block_SIZE-2
  2382.         dc    2
  2383.  
  2384. P61_temp2    dcb.b    Channel_Block_SIZE-2
  2385.         dc    4
  2386.  
  2387. P61_temp3    dcb.b    Channel_Block_SIZE-2
  2388.         dc    8
  2389.  
  2390. P61_cn        dc    0
  2391. P61_dma        dc    $8200
  2392. P61_rowpos    dc    0
  2393. P61_slen    dc    0
  2394. P61_speed    dc    0
  2395. P61_speed2    dc    0
  2396. P61_speedis1    dc    0
  2397. P61_spos    dc.l    0
  2398.  
  2399.     ifeq    system
  2400. P61_vektori    dc.l    0
  2401. P61_oldlev6    dc.l    0
  2402.     endc
  2403.  
  2404. P61_ofilter    dc    0
  2405. P61_timers    dc.l    0
  2406.  
  2407.     ifne    CIA
  2408. P61_tintti    dc.l    0
  2409. P61_thi        dc.b    0
  2410. P61_tlo        dc.b    0
  2411. P61_thi2    dc.b    0
  2412. P61_tlo2    dc.b    0
  2413. P61_timer    dc.l    0
  2414.     endc
  2415.  
  2416.     ifne    P61_pl
  2417. P61_plcount    dc    0
  2418. P61_plflag    dc    0
  2419. P61_plreset    dc    0
  2420. P61_plrowpos    dc    0
  2421. P61_looppos    dcb.b    12*channels
  2422.     endc
  2423.  
  2424.     ifne    P61_pde
  2425. P61_pdelay    dc    0
  2426. P61_pdflag    dc    0
  2427.     endc
  2428.  
  2429. P61_samples    dcb.b    16*31
  2430. P61_emptysample    dcb.b    16
  2431. P61_positionbase dc.l    0
  2432. P61_possibase    dc.l    0
  2433. P61_patternbase    dc.l    0
  2434. P61_intaddr    dc.l    0
  2435.  
  2436.     ifne    system
  2437. P61_server    dc    0
  2438. P61_miscbase    dc.l    0
  2439. P61_audioopen    dc.b    0
  2440. P61_sigbit    dc.b    -1
  2441. P61_ciares    dc.l    0
  2442. P61_craddr    dc.l    0,0,0
  2443. P61_dat        dc    $f00
  2444. P61_timerinterrupt dc    0,0,0,0,127
  2445. P61_timerdata    dc.l    0,0,0
  2446. P61_timeron    dc    0
  2447. P61_allocport    dc.l    0,0
  2448.         dc.b    4,0
  2449.         dc.l    0
  2450.         dc.b    0,0
  2451.         dc.l    0
  2452. P61_reqlist    dc.l    0,0,0
  2453.         dc.b    5,0
  2454. P61_allocreq    dc.l    0,0
  2455.         dc    127
  2456.         dc.l    0
  2457. P61_portti    dc.l    0
  2458.         dc    68
  2459.         dc.l    0,0,0
  2460.         dc    0
  2461. P61_reqdata    dc.l    0
  2462.         dc.l    1,0,0,0,0,0,0
  2463.         dc    0
  2464. P61_audiodev    dc.b    'audio.device',0
  2465.  
  2466. P61_cianame    dc.b    'ciab.resource',0
  2467. P61_timeropen    dc.b    0
  2468. P61_timerint    dc.b    'P61_TimerInterrupt',0,0
  2469.     endc
  2470. P61_etu
  2471.         even
  2472.  
  2473. ******** END OF BINARY FILE **************
  2474.  
  2475. ;    section    chip,data_c
  2476. ;P61_data    incbin    "P61:P61.stay cool..."
  2477. ;P61_smp    incbin    "ram:SMP.fields of green"
  2478.  
  2479. ;    section    smp,bss_c
  2480. ;samples    ;ds.b    $10000        ;uncomment if you have packed samples
  2481.                 ;and insert sample buffer length
  2482.